<template>
	<view class="tabbar">		
		<view v-for="(data,index) in list" :key="index" @click="change(index)">
			<img :src="current==index?data.selectedIconPath:data.iconPath" alt="" srcset="">
			<text :class="[current==index?'active111':'']">{{data.text}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			current: Number
		},
		created() {
			console.log(this.current)
		},
		data() {
			return {
				"list": [
					{
						"text": "首页",
						"iconPath": "../../static/tabbar/home.png",
						"selectedIconPath": "../../static/tabbar/home-active.png",
						"pagePath": "../home/home"
					},
					{
						"text": "分类",
						"iconPath": "../../static/tabbar/cate.png",
						"selectedIconPath": "../../static/tabbar/cate-active.png",
						"pagePath": "../cate/cate"
					},
					{
						"text": "购物车",
						"iconPath": "../../static/tabbar/cart.png",
						"selectedIconPath": "../../static/tabbar/cart-active.png",
						"pagePath": "../cart/cart"
					},
					{
						"text": "我的",
						"iconPath": "../../static/tabbar/my.png",
						"selectedIconPath": "../../static/tabbar/my-active.png",
						"pagePath": "../my/my"
					}
				]
			}
		},
		methods: {
			change(index){
				uni.switchTab({
				   url:this.list[index].pagePath
				});
			}
		}
	}
</script>

<style>
	.tabbar{
		display: flex;
		padding-bottom: 50rpx;
	}
	.tabbar view{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		flex: 1;
	}
	.tabbar view img{
		width: 50rpx;
		height: 50rpx;
	}
	.active111{
		color: red;
	}
</style>
